import './iconfont/iconfont.css'
import './style.css'
import BwyButton from "./components/BwyButton/BwyButton.vue";
import BwyDate from "./components/BwyDate/index.js";
import BwyCheckbox from "./components/from/BwyCheckbox.vue";
import BwyForm from "./components/from/BwyForm.vue";
import BwyFormItem from "./components/from/BwyFormItem.vue";
import BwyInput from "./components/from/BwyInput.vue";
import BwyRadioGroup from "./components/from/BwyRadioGroup.vue";
import BwyRadioItem from "./components/from/BwyRadioItem.vue";
import BwySwitch from "./components/from/BwySwitch.vue";
import BwySelect from "./components/BwySelect/BwySelect.vue"
import BwyTag from "./components/BwyTag/src/index.vue"
import BwyDialog from "./components/BwyDialog/src/index.vue"
import { message } from './components/BwyMessage/index.js'
import WIcon from "./components/w-icon.vue";
import formComponents from './components/from/index.js'

const components = {}
for(let i = 0; i < Object.keys(formComponents).length; i++) {
    const name = Object.keys(formComponents)[i]
    components[name] = formComponents[name]
}

const install = function (Vue) {
    if (install.installed) return;
    install.installed = true;

    Object.keys(components).forEach(key => {
        Vue.component(key, components[key]);
    });
}

// 自动安装
if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue);
}

export {
    install,
    BwyButton,
    BwyDate,
    BwyCheckbox,
    BwyForm,
    BwyFormItem,
    BwyInput,
    BwyRadioGroup,
    BwyRadioItem,
    BwySwitch,
    BwySelect,
    BwyTag,
    BwyDialog,
    message,
    WIcon
}
